<?php

namespace App\Models;

use App\Helpers\RequestCriteria;
use App\Helpers\BaseModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Enterprise extends Model
{
    use HasFactory, RequestCriteria, BaseModel;

    protected $fillable = [
        'name',
        'contact',
        'contact_phone',
        'type',
        'info',
        'remarks',
    ];

    protected $casts = [
        'updated_at' => 'datetime:Y-m-d H:i:s',
        'created_at' => 'datetime:Y-m-d H:i:s',
        'type' => 'array',
    ];

    public function users()
    {
        return $this->belongsToMany(User::Class);
    }

    public function vehicleTeams()
    {
        return $this->hasMany(VehicleTeam::Class);
    }

    public function energyStoragerStation()
    {
        return $this->hasMany(EnergyStoragerStation::Class);
    }

    public function chagerStation()
    {
        return $this->hasMany(chagerStation::Class);
    }

    public function vehicles()
    {
        return $this->hasManyThrough(Vehicle::Class, VehicleTeam::Class);
    }

    public function chagers()
    {
        return $this->hasManyThrough(Charger::Class, ChargerStation::Class);
    }

    public function energyStoragers()
    {
        return $this->hasManyThrough(EnergyStorager::Class, EnergyStoragerStation::Class);
    }
}
